<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

require_once 'eleontev/Validator.php';


class SettingValidator
{
	 
	function validate($values) {
		
		//$required = array('support_email');

		
		$v =& new Validator($values, true);
		
		//$v->required('required_msg', $required);
		//$v->regex('email_msg', 'email', 'support_email');
		
		if(!$this->isFileExists($values['page_to_load'])) {
			$v->setError('page_not_exists_msg', '');
		}
		
		return $v->getErrors();
	}
	

	
	// check is page exists and reachable 
	function isFileExists($file) {
		
		$ret = true;
		
		if('default' != strtolower($file)) {
				
			$files = explode(';', $file);
			$files = (!$files) ? $files = array($file) : $files;
			
			foreach($files as $val) {
				if(@!fopen(trim($val), "rb")) {
					$ret = false;
					break;
				}					
			}
		}		

		return $ret;
	}
}
?>